import request from '@/utils/request'

/**
 * 获取组织架构接口函数
 * @returns
 */
export const getDepartments = () => {
  return request({
    url: '/company/department'
  })
}

/**
 * 根据部门id去删除子部门
 * @param {*} id
 * @returns
 */
export const delDepartments = (id) => {
  return request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}

/**
 * 添加一个部门的接口函数
 * @param {Object} data
 * @returns
 */
export const addDepartments = (data) => {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 * 根据部门id获取部门详情数据
 * @param {String} id  - 部门id
 * @returns
 */
export const getDepartDetail = (id) => {
  return request({
    url: `/company/department/${id}`
  })
}

/**
 * 根据部门id编辑部门详情
 * @param {*} data - 部门详情数据
 * @returns
 */
export function updateDepartments(data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  })
}

